#ifndef DELEGATES
#define DELEGATES

#include <QItemDelegate>
#include <complex>

class MatrixSheet;
class BaseDelegate : public QItemDelegate
{
    Q_OBJECT
public:
    explicit BaseDelegate(MatrixSheet* sheet);

protected:
    MatrixSheet* m_matrixSheet;
};

class SpinBoxDelegate : public BaseDelegate
{
    Q_OBJECT

public:
    SpinBoxDelegate(MatrixSheet* sheet);

    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
                          const QModelIndex &index) const Q_DECL_OVERRIDE;

    void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE;
    void setModelData(QWidget *editor, QAbstractItemModel *model,
                      const QModelIndex &index) const Q_DECL_OVERRIDE;

    void updateEditorGeometry(QWidget *editor,
        const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE;
};

class DoubleSpinBoxDelegate : public BaseDelegate
{
    Q_OBJECT

public:
    DoubleSpinBoxDelegate(MatrixSheet* sheet);

    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
                          const QModelIndex &index) const Q_DECL_OVERRIDE;

    void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE;
    void setModelData(QWidget *editor, QAbstractItemModel *model,
                      const QModelIndex &index) const Q_DECL_OVERRIDE;

    void updateEditorGeometry(QWidget *editor,
        const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE;
};

class ComplexSpinBoxDelegate : public BaseDelegate
{
    Q_OBJECT

public:
    ComplexSpinBoxDelegate(MatrixSheet* sheet);

    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
                          const QModelIndex &index) const Q_DECL_OVERRIDE;

    void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE;
    void setModelData(QWidget *editor, QAbstractItemModel *model,
                      const QModelIndex &index) const Q_DECL_OVERRIDE;

    void updateEditorGeometry(QWidget *editor,
        const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE;
};

#endif // DELEGATES

